package com.example.learnquartz.quartz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @version v1.0
 * @description:
 * @author: 47 on 2020/4/9 17:12
 */
@Component
public class Initialization implements ApplicationRunner {

    @Autowired
    private SchedulerManager schedulerManager;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        SchedulerJob schedulerJob = new SchedulerJob();
        schedulerJob.setName(MonitorCronJob.JOB_NAME);
        schedulerJob.setGroup(MonitorCronJob.GROUP_NAME);
        schedulerJob.setCron(MonitorCronJob.CRON);
        schedulerJob.setDesc(MonitorCronJob.DESC);
        schedulerJob.setJobClass(MonitorCronJob.class.getName());
        schedulerManager.activeJob(schedulerJob);
    }
}
